<?php

namespace addons\company\controller\api;

use app\common\controller\Api;
use EasyWeChat\Factory;
use think\Env;

class Config extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = '*';

    public function jssdkConfig()
    {
        $config = [
            'app_id' => Env::get('gzh.appid'),
            'secret' => Env::get('gzh.app_secret'),
            'response_type' => 'array',
        ];

        $url = $this->request->post('url', '', 'trim');
        $api = explode('-', $this->request->post('api_list', ''));

        $app = Factory::officialAccount($config);

        $app->jssdk->setUrl($url);

        $data = $app->jssdk->buildConfig($api,  true, false, false);

        $this->success('成功生成', $data);

    }
}
